package com.bsdsma.visonManagementSystemapp.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * 教师表
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@KeySequence(dbType = DbType.MYSQL)
@TableName("teacher")
@Table(name = "teacher", indexes = {
    @Index(name = "idx_un_account_status", columnList = "account,status", unique = true),
    @Index(name = "idx_un_gonghao_status", columnList = "gonghao,status", unique = true)
})
public class Teacher extends User implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Column(length = 20)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.AUTO)
    private Long id;

    @Column(name = "account", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String account;

    @Column(name = "password", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String password;

    @Column(name = "head_img_key", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String headImgKey;

    @Column(name = "name", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String name;

    @Column(name = "cellphone_number", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String cellphoneNumber;

    @ManyToOne
    @JoinColumn(name = "xuexiao_id", insertable = false, updatable = false)
    @TableField(exist = false)
    private School xuexiao;

    @Column(name = "xuexiao_id")
    @TableField("xuexiao_id")
    private Long xuexiaoId;

    @Column(name = "gonghao", columnDefinition = "bigint DEFAULT NULL")
    private Long gonghao;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date ct;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date ut;

    @Column(nullable = false)
    private Integer status;

    @Override
    public String getRole() {
        return "教师";
    }
} 